﻿using System;
using System.Linq;
using Orange.Logistics.Models;
using Orange.Logistics.Infrastructure;
using Orange.Logistics.Services;
using System.Web.Mvc;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Orange.Logistics.Controllers {

    public class MemorycardController : BaseController<Memorycard> {

        private readonly IMemorycardService service;

        public MemorycardController(IMemorycardService service)
            : base(service) {
            this.service = service;
        }

        protected override Func<Memorycard, object> GetOrderBy(string sort) {
            return m => {
                switch (sort) {
                    case "Memoryid":
                        return m.Memoryid;
                    case "Memorycard":
                        return m.MemorycardName;
                    case "Scurinrpieces":
                        return m.Scurinrpieces;
                    case "ScurinWeight":
                        return m.ScurinWeight;
                    case "ScuroutWeight":
                        return m.ScuroutWeight;
                    case "Scuroutrpieces":
                        return m.Scuroutrpieces;
                    case "Sweight":
                        return m.Sweight;
                    case "Srpieces":
                        return m.Srpieces;
                    default:
                        return m.Memoryid;
                }
            };
        }

        protected override void Dispose(bool disposing) {
            if (disposing) {
                service.Dispose();
            }
        }
    }
}